using UnityEngine;

public class BattleAttack_Siplett_Homing : MonoBehaviour
{
	[Header("-= Movement =-")]
	[SerializeField]
	private float acceleration = 5f;

	[SerializeField]
	private float maxSpeed = 20f;

	[SerializeField]
	private float rotationSpeed = 2f;

	[SerializeField]
	private float rotationDuration = 3f;

	private Vector2 velocity = Vector2.zero;

	private float rotationTimer;

	private void Start()
	{
		rotationSpeed = Random.Range(2, 4);
	}

	private void Update()
	{
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Battle_PlayerSoul.Instance == (Object)null)
		{
			Debug.LogWarning((object)"Battle_PlayerSoul.Instance is not set.");
			return;
		}
		rotationTimer += Time.deltaTime;
		if (rotationTimer >= rotationDuration)
		{
			rotationSpeed = 0f;
		}
		Vector2 val = Vector2.op_Implicit(((Component)Battle_PlayerSoul.Instance).transform.position) - Vector2.op_Implicit(((Component)this).transform.position);
		Vector2 normalized = ((Vector2)(ref val)).normalized;
		float num = Mathf.Atan2(normalized.y, normalized.x) * 57.29578f;
		if (rotationSpeed > 0f)
		{
			float num2 = Mathf.LerpAngle(((Component)this).transform.eulerAngles.z, num, rotationSpeed * Time.deltaTime);
			((Component)this).transform.rotation = Quaternion.Euler(0f, 0f, num2);
		}
		Vector2 val2 = Vector2.op_Implicit(((Component)this).transform.right);
		velocity += val2 * acceleration * Time.deltaTime;
		if (((Vector2)(ref velocity)).magnitude > maxSpeed)
		{
			velocity = ((Vector2)(ref velocity)).normalized * maxSpeed;
		}
		Transform transform = ((Component)this).transform;
		transform.position += Vector2.op_Implicit(velocity) * Time.deltaTime;
	}
}
